// 根据 APIs.md 中的商品管理模块定义类型

export interface Product {
  id: number
  productId: number // 添加 productId 字段
  name: string
  description: string
  price: number
  originalPrice: number
  brandId: number
  brandName: string
  categoryId: number
  categoryName: string
  typeId: number
  typeName: string
  status: 'active' | 'inactive'
  mainImage: string
  images: string[]
  colors: Color[]
  sizes: Size[]
  stock: number
  sales: number
  rating: number
  reviewCount: number
  createTime: string
  updateTime: string
}

export interface ProductDetail extends Product {
  productId: number // 添加 productId 字段
  specifications: Record<string, string | number | boolean | null>
  tags: string[]
  isHot: boolean
  isNew: boolean
  isRecommended: boolean
}

export interface ProductQuery {
  page?: number
  size?: number
  keyword?: string
  brandId?: number
  categoryId?: number
  typeId?: number
  colorId?: number
  sizeId?: number
  gender?: string
  minPrice?: number
  maxPrice?: number
  sortBy?: 'price' | 'sales' | 'date' | 'rating'
  sortOrder?: 'asc' | 'desc'
  status?: string
}

export interface ProductResponse {
  list: Product[]
  total: number
  page: number
  size: number
}

export interface Category {
  id: number
  name: string
  description: string
  parentId?: number
  level: number
  sort: number
  status: 'active' | 'inactive'
  icon?: string
  image?: string
  createTime: string
  updateTime: string
}

export interface Brand {
  // 与后端 Brands 实体对齐
  brand_id: number
  brand_name: string
  status: number
  remarks?: string
}

// 后台“类型”实体（与后端 Types 对齐）
export interface Types {
  typeId: number
  typeName: string
  status: string
  icon?: string
}

// 后台广告、友情链接、评价的最小类型（与后端实体对齐）
export interface Advertisement {
  id: number
  title: string
  imageUrl: string
  linkUrl: string
  position: string
  status: number
  sortOrder: number
  startTime?: string
  endTime?: string
  createdAt?: string
  updatedAt?: string
}

export interface PartnerLink {
  id: number
  linkName: string
  linkUrl: string
  logoUrl?: string
  sortOrder?: number
  createdAt?: string
  updatedAt?: string
}

export interface ProductReview {
  id: number
  orderItemId: number
  userId: number
  spuId: number
  skuId: number
  rating: number
  comment: string
  createdAt: string
}

export interface Color {
  // 与后端 Colors 实体对齐
  colorId: number
  colorName: string
  status: string
  remarks?: string
}

export interface Size {
  // 与后端 Sizes 实体对齐
  sizeId: number
  shoeSize: string
  status: number
  remarks?: string
}

export interface ProductImage {
  // 与后端 ProductImage 实体对齐
  imageId: number
  shoeId: number
  imageUrl: string
  imageName?: string
  imageType?: string
  sortOrder?: number
  isMain?: number
  status?: number
  createdAt?: string
  updatedAt?: string
}

export interface Stock {
  // 与后端 Stock 实体对齐（SKU）
  skuId: number
  shoeId: number
  sizeId: number
  colorId: number
  price: number
  discountPrice?: number
  stockQuantity: number
}

// 后台管理用：与后端 Shoes 实体字段对齐的最小定义
export interface Shoes {
  shoeId: number
  serialNumber: string
  name: string
  price: number
  discountPrice?: number
  launchDate?: string
  originPlace?: string
  gender?: string
  description?: string
  detailedInfo?: string
  itemPoints?: number
  status: string
  productImageUrl?: string
  salesVolume?: number
  brand_id: number
  typeId: number
  productImages?: ProductImage[]
}

// 与后端 ProductVO 完全匹配的类型定义
export interface ProductVO {
  shoeId: number
  serialNumber: string
  name: string
  price: number
  discountPrice?: number
  productImageUrl?: string
  productImages?: ProductImage[]
  salesVolume?: number
  gender?: string
  brand?: {
    brand_id: number
    brand_name: string
    brandLogo?: string
  }
  type?: {
    typeId: number
    typeName: string
  }
  availableColors?: Array<{
    colorId: number
    colorName: string
    colorValue: string
  }>
  availableSizes?: Array<{
    sizeId: number
    sizeName: string
  }>
}

// 前台商品查询相关类型
export interface ProductSearchQuery {
  keyword?: string
  brand_id?: number
  categoryId?: number
  typeId?: number
  colorId?: number
  sizeId?: number
  minPrice?: number
  maxPrice?: number
  page?: number
  size?: number
  sortBy?: 'price' | 'sales' | 'date' | 'rating'
  sortOrder?: 'asc' | 'desc'
}

export interface ProductSearchResponse {
  list: Product[]
  total: number
  page: number
  size: number
  brand_name?: string
  categoryName?: string
}
